// import { Message } from 'ant-design-vue'

function showMsg (msg, code, dispatch) {
    const inBrower = typeof window !== undefined && window.setTimeout

    if (inBrower) {
        // console.log('showMsg:',msg || '获取数据失败')
        // Message.error(msg || '获取数据失败')
    }
    // console.log('msg err code:', code)
    if (code === 413) {
        let timer = 0

        dispatch('logout', {}, { root: true }).then(() => {
            if (inBrower) {
                if (timer) { clearTimeout(timer) }
                timer = setTimeout(() => {
                    window.location.href = '/'
                }, 100)
            }
        }).catch(err => {
            console.log('-----logout err-----')
            console.log(err)

            if (inBrower) {
                if (timer) { clearTimeout(timer) }
                timer = setTimeout(() => {
                    window.location.href = '/'
                }, 100)
            }
        })
    }
}

export default showMsg